import request from '@/config/axios'

// 教材分类 VO
export interface ResourceVO {
  id: number // 主键ID
  name: string // 教材类目名称
  type: string // 教材类型名称
}

// 教材分类 API
export const ResourceApi = {
  // 查询教材分类分页
  getResourcePage: async (params: any) => {
    return await request.get({ url: `/kt/resource/page`, params })
  },

  // 查询教材分类详情
  getResource: async (id: number) => {
    return await request.get({ url: `/kt/resource/get?id=` + id })
  },

  // 新增教材分类
  createResource: async (data: ResourceVO) => {
    return await request.post({ url: `/kt/resource/create`, data })
  },

  // 修改教材分类
  updateResource: async (data: ResourceVO) => {
    return await request.put({ url: `/kt/resource/update`, data })
  },

  // 删除教材分类
  deleteResource: async (id: number) => {
    return await request.delete({ url: `/kt/resource/delete?id=` + id })
  },

  // 导出教材分类 Excel
  exportResource: async (params) => {
    return await request.download({ url: `/kt/resource/export-excel`, params })
  },

// ==================== 子表（教材资源） ====================

  // 获得教材资源列表
  getJiaocaiListByResourceId: async (resourceId) => {
    return await request.get({ url: `/kt/resource/jiaocai/list-by-resource-id?resourceId=` + resourceId })
  },
}